package cn.zd.demo1.broadcast;

import static cn.zd.demo1.broadcast.MyBroadCastConstant.ACTION_ORDER;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

public class OrderBReceiver extends BroadcastReceiver {
    private Context context;

    public OrderBReceiver(Context context) {
        this.context = context;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        if(intent!=null && intent.getAction() == ACTION_ORDER) {
            Toast.makeText(context,"B接收到有序广播"+intent.getStringExtra("data"),Toast.LENGTH_SHORT).show();
            if(intent.getBooleanExtra("abort",false)){
                // 中断广播
                abortBroadcast();
            }
        }
    }
}
